<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>班级管理 - 智能教育系统</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            margin: 0;
            padding-top: 80px;
        }

        .class-container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 2rem;
        }

        .class-card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }

        .class-card:hover {
            transform: translateY(-5px);
        }

        .btn-primary {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(110, 142, 251, 0.3);
        }

        .alert {
            padding: 1rem;
            border-radius: 8px;
            margin-bottom: 1rem;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from {
                transform: translateY(-10px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
    </style>
</head>
<body>
    <!-- 引入导航栏 -->
    <div th:replace="fragments/navbar :: navbar"></div>

    <div class="class-container">
        <div class="flex justify-between items-center mb-6">
            <h1 class="text-3xl font-bold text-gray-800">班级管理</h1>
            <a href="/class/create" class="btn-primary">创建新班级</a>
        </div>

        <!-- 提示消息 -->
        <div th:if="${success}" class="alert bg-green-100 text-green-700" th:text="${success}"></div>
        <div th:if="${error}" class="alert bg-red-100 text-red-700" th:text="${error}"></div>

        <!-- 班级列表 -->
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            <div th:each="class : ${classes}" class="class-card p-6">
                <div class="flex justify-between items-start mb-4">
                    <div>
                        <h3 class="text-xl font-semibold text-gray-800" th:text="${class.className}"></h3>
                        <p class="text-gray-600" th:text="${class.grade}"></p>
                    </div>
                    <div class="flex space-x-2">
                        <a th:href="@{/class/edit/{id}(id=${class.id})}" 
                           class="text-blue-600 hover:text-blue-800">
                            编辑
                        </a>
                        <form th:action="@{/class/delete/{id}(id=${class.id})}" 
                              method="post" 
                              class="inline"
                              onsubmit="return confirm('确定要删除这个班级吗？');">
                            <button type="submit" class="text-red-600 hover:text-red-800">
                                删除
                            </button>
                        </form>
                    </div>
                </div>
                <p class="text-gray-600 mb-4" th:text="${class.description}"></p>
                <div class="flex justify-between items-center">
                    <span class="text-sm text-gray-500">
                        试卷数量: <span th:text="${class.exams.size()}">0</span>
                    </span>
                    <a th:href="@{/exam/list(classId=${class.id})}" 
                       class="text-blue-600 hover:text-blue-800">
                        查看试卷
                    </a>
                </div>
            </div>
        </div>
    </div>
</body>
</html> 